home *** CD-ROM | disk | FTP | other *** search
- Path: free1-slip207.tele.queensu.ca!user
- From: 3gl21@qlink.queensu.ca (Gregory Lo)
- Newsgroups: comp.windows.x.motif,comp.lang.c++
- Subject: Re: MOTIF Callbacks, C++ Member Functions - SOLVED
- Date: Wed, 21 Feb 1996 20:07:53 -0608
- Organization: Queen's University
- Distribution: inet
- Message-ID: <3gl21-2102962007530001@free1-slip207.tele.queensu.ca>
- References: <4f6oau$c4m@knot.queensu.ca> <4f9fbo$7ju@news1.halcyon.com> <4gbf05$6d8@rex.sfe.com.au> <4gc9p3$s7s@tech.cftnet.com> <4gfdgb$n2d@newdelph.cig.mot.com>
- NNTP-Posting-Host: free1-slip207.tele.queensu.ca
- X-Newsreader: Yet Another NewsWatcher 2.2.0b4
-
- In article <4gfdgb$n2d@newdelph.cig.mot.com>, khosravn@rtsg.mot.com
- (Shahram Khosravani) wrote:
-
- > In article <4gc9p3$s7s@tech.cftnet.com>, wcowley@cftnet.com (Wes Cowley)
- writes:
- > |> Paul Hatchman (paul@sfe.com.au) wrote:
- > |> : danubius@chinook.halcyon.com () writes:
- > |> :
- > |> : >Wintermute <3mal5@qlink.queensu.ca> wrote:
- > |> : >>
- > |> : >>The solution was to declare a static member function which is
- used as a
- > |> : >>callback. Since it is static, there is no 'this' pointer, and it
- works
- > |> : >>fine. To access the particular class instance, pass the 'this'
- pointer
- > |> : >>as client data when installing the callback, and it will be available
- > |> : >>when the static member function is called back.
- >
- > I don't do much C++ these days, but I think that the 'this' pointer you
- > are passing in as client data, can only be used to access other static
- > data/function members. It can not access any non-static data members or call
- > any non-static methods. True/False ?
-
- The 'this' pointer is a member of an object that points to the object
- itself. It will also point to all the information needed to access and
- object's non-static members and methods as well as static ones.
-
- Non-static methods require the 'this' pointer to be passed to them
- implicitly in order to refer to the object in question, and access other
- methods and members (non-static or otherwise).
-
- However, since static members are not implicitly passed the 'this'
- pointer, they can normally only access other static members and methods.
- Static members and methods exist independantly of *any* object, they
- belong to the object's class. This is probably what you are thinking of.
-
- Depending on your situation, you might have to typecast the 'this' pointer
- when you pass it as client data, and then typecast it back when you access
- it.
- Greg Lo
-